package com.llj.OrderingSystem.common;

/**
 * 基于ThreadLocal封装工具类，用户保存和获取当前登录用户id
 * @author yuerenge
 * @date 2023/03/13
 */
public class BaseContext {
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    /**
     * 设置当前线程id
     * @param id id
     */
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }

    /**
     * 得到当前线程id
     * @return {@link Long}
     */
    public static Long getCurrentId (){
        return threadLocal.get();
    }
}
